use "...Komatsu Collins Data.dta" 

* Models/Figures in Manuscript *

* Figure 1 / Appendix Table 2 *
* 1986-2022 time frame - all justices *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc

* Figure 1 - plot mean effects *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.332 lctdir=0 conresource=3.25 libresource=1.88 extreme=.272 tenure=13.9 csi=2.46 complexity=0.065 casecount100=2.33) post
* mean *
coefplot, drop(_cons) xline(0) levels (95) xlabel(-.3(.05).3) title("Marginal Effects from Mean Equation") ylabel(,labsize(smallmedium)) xlabel(,labsize(smallmedium)) ylab(1 "Federalist Society" 2 "Ideology" 3 "Lower Court Direction" 4 "Conservative Resources" 5 "Liberal Resources")

* Figure 1 - plot variance *
* need to input variance matrix after clearing data*
clear all
matrix input A = (-.2033363, -.3201957, -.0051868 , -.0682482, -.0370661, -.0537586 \  .1033459 .2356048 .0026471 .0175091 .0454885 .0158866 )
coefplot mat(A), se(2) xline(0) ylab(1 "Federalist Society" 2 "Ideological Extremism" 3 "Tenure" 4 "Case Salience" 5 "Case Complexity" 6 "Prior Cases") xlabel(-.8(.2).8)title("Coefficients from Variance Equation") 


* Figure 2 / Appendix Table 3 *
* need to reload data - repeat line 1 *
* 1986-2022 time frame - Republican justices *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985 & republican==1, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc

* Figure 2 - plot mean effects *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985 & republican==1, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.2157 lctdir=0 conresource=3.26 libresource=1.89 extreme=.312 tenure=14.04 csi=2.50 complexity=0.075 casecount100=2.39) post
* mean *
coefplot, drop(_cons) xline(0) levels (95) xlabel(-.3(.05).3) title("Marginal Effects from Mean Equation") ylabel(,labsize(smallmedium)) xlabel(,labsize(smallmedium)) ylab(1 "Federalist Society" 2 "Ideology" 3 "Lower Court Direction" 4 "Conservative Resources" 5 "Liberal Resources")

* Figure 2 - plot variance *
* need to input variance matrix after clearing data*
clear all
matrix input A = (-.2950203, -.1044929, -.00826, -.0446732, -.0036767, -.043834 \  .1305523 .3348347 .0042124 .021131 .0661603 .0181726 )
coefplot mat(A), se(2) xline(0) ylab(1 "Federalist Society" 2 "Ideological Extremism" 3 "Tenure" 4 "Case Salience" 5 "Case Complexity" 6 "Prior Cases") xlabel(-.8(.2).8)title("Coefficients from Variance Equation") 




* Models in Appendix *

* Appendix Table 2 *
* need to reload data - repeat line 1 *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.332 lctdir=0 conresource=3.25 libresource=1.88 extreme=.272 tenure=13.9 csi=2.46 complexity=0.065 casecount100=2.33) post

* Information on FedSoc justices and ideology *
* 11 most conservative justices *
tab name if ideology<.32 & e(sample)
* 5 most conservative justices *
tab name if ideology<.11 & e(sample)
* Ideology score for FedSoc and Non-FedSoc *
ttest ideology if e(sample), by(fedsoc)
* Ideology score for FedSoc and Non-FedSoc - only Republicans  *
ttest ideology if e(sample) & republican==1, by(fedsoc)


* Appendix Table 3 *
* 1986-2022 time frame - Republican justices *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985 & republican==1, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.2157 lctdir=0 conresource=3.26 libresource=1.89 extreme=.312 tenure=14.04 csi=2.50 complexity=0.075 casecount100=2.39) post



* Appendix Table 4 *
* Repeat main model to get correlations *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
* correlations of variables in the model *
corr fedsoc ideology lctdir conresource libresource extreme tenure csi complexity casecount100 if e(sample)
* model w/o Ideology and Ideological Extremism *
hetprob justdir fedsoc lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc lctdir conresource libresource) at(fedsoc=0 lctdir=0 conresource=3.25 libresource=1.88 tenure=13.9 csi=2.46 complexity=0.065 casecount100=2.33) post



* Appendix Table 5 1953-2022 *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.344 lctdir=0 conresource=3.29 libresource=1.92 extreme=.280 tenure=13.9 csi=2.5 complexity=0.78 casecount100=2.79)



* Appendix Table 6 1982-2022 *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1& term>1981, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.344 lctdir=0 conresource=3.29 libresource=1.92 extreme=.280 tenure=13.9 csi=2.5 complexity=0.78 casecount100=2.79)



* Appendix Table 7 - swapping FedSoc for Republican Appointee variable *
hetprob justdir republican ideology lctdir conresource libresource if decisionType==1 & term>1985, het(republican extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
precalc
margins, dydx(republican ideology lctdir conresource libresource) at(republican=0 ideology=.344 lctdir=0 conresource=3.29 libresource=1.92 extreme=.280 tenure=13.9 csi=2.5 complexity=0.78 casecount100=2.79)



* Appendix Table 8 - term dummies *
hetprob justdir fedsoc ideology lctdir conresource libresource i.term if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.332 lctdir=0 conresource=3.25 libresource=1.88 extreme=.272 tenure=13.9 csi=2.46 complexity=0.065 casecount100=2.33) post
* Compare BIC *
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
estat ic
hetprob justdir fedsoc ideology lctdir conresource libresource i.term if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
estat ic



* Appendix Table 9 - homoskedastic probit *
probit justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc ideology lctdir conresource libresource) at(fedsoc=0 ideology=.332 lctdir=0 conresource=3.25 libresource=1.88) post



* Appendix Table 10 - include number of FedSoc justices in mean equation *
hetprob justdir fedsoc fedsocnumber ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
esttab, se ar2 label nogaps nolines star(* 0.05 ** 0.01 *** 0.001) b(a2) se(a2)
estat sum
precalc
margins, dydx(fedsoc fedsocnumber ideology lctdir conresource libresource) at(fedsoc=0 ideology=.332 lctdir=0 conresource=3.25 libresource=1.88 extreme=.272 tenure=13.9 csi=2.46 complexity=0.065 casecount100=2.33) post
* Compare BIC *
hetprob justdir fedsoc fedsocnumber ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
estat ic
hetprob justdir fedsoc ideology lctdir conresource libresource if decisionType==1 & term>1985, het(fedsoc extreme tenure csi complexity casecount100) vce(cluster caseId)
estat ic